package com.ccb.lms.util;

import java.util.Map;

import com.ccb.lms.dto.ReaderBorrowCopyBookAuthority;
import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;
import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;

public class ReaderBorrowCopyBookAuthorityConverter extends
		DefaultTypeConverter {

	@Override
	public Object convertValue(Map context, Object value, Class toType) {

		try {

			if (toType == ReaderBorrowCopyBookAuthority.class) {// 当字符串向ReaderBorrowCopyBookAuthority类型转换时

				String[] params = (String[]) value;

				return ReaderBorrowCopyBookAuthority.toType(params[0]);

			} else if (toType == String.class) {// 当ReaderBorrowCopyBookAuthority转换成字符串时

				ReaderBorrowCopyBookAuthority readerBorrowCopyBookAuthority = (ReaderBorrowCopyBookAuthority) value;

				return readerBorrowCopyBookAuthority.toString();

			}

		} catch (ParseException e) {
			e.printStackTrace();
		}

		return null;

	}

}
